//
//  OrderCommentSuccessViewController.m
//  PigMarket
//
//  Created by 张敬 on 2019/9/15.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "OrderCommentSuccessViewController.h"

@interface OrderCommentSuccessViewController ()

@property (nonatomic, strong) UIImageView *bgImg;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *detailLab;


@end

@implementation OrderCommentSuccessViewController

- (void)setupUI{
    
    {
        self.baseNavView.navTitleLabel.text = @"评价成功";
    }
    
    {
        [self.view addSubview:self.bgImg];
        [self.view addSubview:self.tableView];
    }
}

- (void)setupLayout
{
    [self.bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(TJ_NavBarHeight);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(140 + TJ_StatusBarHeight);
    }];
    
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(28);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(26);
    }];
    
    [self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLab.mas_bottom).offset(5);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(17);
    }];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.bgImg.mas_top).offset(113);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo( -(TJ_SafeAreaBottomHeight));
    }];
}


- (void)initData{
    
    @weakify(self);
    [[[MeatOrderApi sharedInstance] getOrderEvaluationByGoodId:@1 shopId:@"1"] subscribeNext:^(MeatOrderEvaluationSuccessModel * _Nullable x) {
        
    } error:^(NSError * _Nullable error) {
        
    }];
}

#pragma mark - tableview delegate/dataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if(indexPath.section == 0) return 90;
//    if(indexPath.section == 1)
//    {
//        if (indexPath.row == 0) return 44;
//        if (indexPath.row == 1) return 34;
//        if (indexPath.row == self.model.product_json_str.count +2) return 46;
//        return 76;
//
//    }
    return 115;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *sectionView = [[UIView alloc] init];
    sectionView.backgroundColor = KClearColor;
    return sectionView;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [BaseIndentationTableCell new];
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


#pragma mark - setter methods

#pragma mark - getter methods

- (UIImageView *)bgImg {
    if (!_bgImg) {
        _bgImg = [[UIImageView alloc] init];
        _bgImg.image = [UIImage imageNamed:@"order_comment_bg"];
        _bgImg.userInteractionEnabled = YES;
        
        [_bgImg addSubview:self.titleLab];
        [_bgImg addSubview:self.detailLab];
        
    }
    return _bgImg;
}

- (UILabel *)titleLab{
    
    if (!_titleLab) {
        _titleLab = [UILabel makeLabelWithText:@"感谢您的评价" textColor:KWhiteColor font:mFont(19) textAliment:1];
    }
    return _titleLab;
}

- (UILabel *)detailLab{
    
    if (!_detailLab) {
        _detailLab = [UILabel makeLabelWithText:@"您的评价是我们前进的动力！" textColor:KWhiteColor font:mFont(12) textAliment:1];
        _detailLab.adjustsFontSizeToFitWidth = YES;
    }
    return _detailLab;
}

#pragma mark - override methods

- (void)registerTableViewCell{
    
    [self.tableView registerClass:[BaseIndentationTableCell class] forCellReuseIdentifier:@"UITableViewCell"];

    
    self.tableView.mj_footer.hidden = YES;
    self.tableView.mj_header.hidden = YES;
    self.tableView.backgroundColor = KClearColor;
    
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 10)];
    view.backgroundColor = mBackgroudColor;
    self.tableView.tableFooterView = view;
}


@end
